<?php
  if ($accion == 'alta') {
    $profesor='';
    $aula= '';
    $id_materia= '';
    $fecha='';
    $hora='';
    $numero='';
    $id='';
    $accion= 'insertar';
  }elseif ($accion == 'actualizar') {
    $profesor= $mesa->profesor;
    $aula= $mesa->aula; 
    $id_materia = $mesa->id_materia;
    $fecha= $mesa->fecha;
    $hora= $mesa->hora;
    $id= $mesa->id_mesa;
  }  
?>


</div>

<div id="principal">
  <section id="parrafo">
     <div id="container_demo" >
        <div id="wrapper">
          <div id="login" class="animate form">
            <form name="formulario" action="<?php echo base_url(); ?>mesas/<?php echo $accion;?>" method="post" > 
              <p> 
                 <label for="usernamesignup" class="uname" >Nombre del Profesor*</label>
                 <input type="text" required="required" name="profesor"  value="<?php echo $profesor;?>"/>
              </p>                             
              <p> 
                   <label for="usernamesignup" class="uname" >Aula*</label>
                   <input type="text" required="required"  name="aula"  value="<?php echo $aula;?>">
                   </textarea>                    
              </p>
              <p> 
                 <label for="usernamesignup" class="uname" >Nombre de la Materia*</label>
                 <select required="required" name="materia"  />
                 <?php
                  if ($id_materia!= '') {
                    foreach ($materia as $materia) {
                      if ($id_materia==$materia->id_materia) {
                  ?>
                        <option value="<?php echo $materia->id_materia; ?>" selected><?php echo  $materia->nombre;?></option>
                  <?php      
                      }else{
                  ?>
                        <option value="<?php echo $materia->id_materia; ?>"><?php echo  $materia->nombre;?></option>
                  <?php  
                      }
                    }                         
                  }else{  
                    foreach ($materia as $materia) {
                  ?>
                    <option value="<?php echo $materia->id_materia; ?>"><?php echo $materia->nombre;?></option>
                  <?php
                    }                    
                  }
                 ?>
                 </select>
              </p>
              <p> 
                 <label for="usernamesignup" class="uname" >Fecha*</label>
                 <input type="date" required="required" name="fecha"  value="<?php echo $fecha;?>"/>
              </p>
              <p> 
                 <label for="usernamesignup" class="uname" >Hora*</label>
                 <input type="time" required="required" name="hora"  value="<?php echo $hora;?>"/>
              </p>
              
                
                <input type="hidden" name="id_mesa" value="<?php echo $id; ?>"/>              
              <p class="signin button">
                 <input type="submit" name="guardar" value="Guardar" />
              </p>        
      </form>
    </div>
  </div>
  </div>
  </section>
  </div>
</div>
</body>
</html>